/*
 * A container class, storing and supplying the information (or reference information) to the data needed for one level layer
 */

package com.anneric;

import java.io.IOException;



public class PicInfoStorage {
	private String originalPicturePath;
	private String modifiedPicturePath;
	private int errorCoordMarginLeft1;
	private int errorCoordMarginTop1;
	private int errorCoordMarginLeft2;
	private int errorCoordMarginTop2;
	private int argsFilled;
	
	public PicInfoStorage(){
		originalPicturePath = "";
		modifiedPicturePath = "";
		errorCoordMarginLeft1 = -1;
		errorCoordMarginTop1 = -1;
		errorCoordMarginLeft2 = -1;
		errorCoordMarginTop2 = -1;
		argsFilled = 0;
	}
	
	public PicInfoStorage(PicInfoStorage pisc){
		originalPicturePath = pisc.originalPicturePath;
		modifiedPicturePath = pisc.modifiedPicturePath;
		errorCoordMarginLeft1 = pisc.errorCoordMarginLeft1;
		errorCoordMarginTop1 = pisc.errorCoordMarginTop1;
		errorCoordMarginLeft2 = pisc.errorCoordMarginLeft2;
		errorCoordMarginTop2 = pisc.errorCoordMarginTop2;
		argsFilled = pisc.argsFilled;
	}
	
	public static int StrToInt(String str){
		return Integer.valueOf(str).intValue();
	}
	
	//
	// setter functions
	//
	
	public void addInfo(String info) throws IOException{
		if (argsFilled == 0){
			originalPicturePath = info;
		}
		else if (argsFilled == 1){
			modifiedPicturePath = info;
		}
		else if (argsFilled == 2){
			errorCoordMarginLeft1 =  StrToInt(info);
		} 
		else if (argsFilled == 3){
			errorCoordMarginTop1 = StrToInt(info);
		}
		else if (argsFilled == 4){
			errorCoordMarginLeft2 = StrToInt(info);
		}
		else if(argsFilled == 5){
			errorCoordMarginTop2 = StrToInt(info);
		} else {
			throw new IOException();
		}
		
		++argsFilled;
		
	}
	//
	// getter functions
	//
	
	public final String getOPP(){
		return originalPicturePath;
	}
	
	public final String getMPP(){
		return modifiedPicturePath;
	}
	
	public final int getMarginL1(){
		return errorCoordMarginLeft1;
	}
	
	public final int getMarginT1(){
		return errorCoordMarginTop1;
	}
	
	public final int getMarginL2(){
		return errorCoordMarginLeft2;
	}
	
	public final int getMarginT2(){
		return errorCoordMarginTop2;
	}
	
	public final boolean hasTwoSpots(){
		return argsFilled==6;
	}
	
	public final int size(){
		return argsFilled;
	}
	
	
}